<template>
  <transition name="box-card">
    <div class="box-card-warp" v-if="show" v-mask="show">
      <div class="box-card" :style="boxStyle">
        <div class="title">{{title}}</div>
        <slot></slot>
        <div class="btns">
          <div class="enter btn" @click="enter">确定</div>
          <div class="esc btn" @click="close">取消</div>
        </div>
        <div class="close" @click="close">
          <i class="iconfont icon-guanbi"></i>
        </div>
      </div>
    </div>
  </transition>
</template>


<script>
import "components/mask"
/* 
  props:
    title: 头部标题
    show: 控制是否显示
    boxStyle: 控制样式
*/
export default {
  props: {
    title: String,
    show: Boolean,
    boxStyle: Object
  },
  methods: {
    close() {
      this.$emit("update:show", false)
    },
    enter() {
      this.$emit("enter")
    }
  }
}
</script>

<style lang="less" scoped>
.box-card-warp {
  text-align: center;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  &::after {
    display: inline-block;
    content: "";
    height: 100%;
    width: 0;
    vertical-align: middle;
  }
}

.box-card {
  display: inline-block;
  vertical-align: middle;
  background-color: #fff;
  border-radius: 5px;
  position: relative;
  padding-bottom: 30px;
  .title {
    position: relative;
    line-height: 64px;
    border-bottom: 1px solid #e5e5e5;
    padding: 0 27px;
    color: #333333;
    font-size: 16px;
    height: 65px;
    margin-bottom: 14px;
    text-align: left;
  }
  .btns {
    text-align: center;
    .btn {
      display: inline-block;
      width: 75px;
      height: 33px;
      text-align: center;
      line-height: 33px;
      box-sizing: border-box;
      border: 1px solid #2a84fc;
      cursor: pointer;
      border-radius: 3px;
      margin-right: 5px;
    }
    .enter {
      color: #fff;
      background-color: #2a84fc;
    }
    .esc {
      color: #2a84fc;
    }
  }
  .close {
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    position: absolute;
    z-index: 202;
    top: -8px;
    right: -9px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0px 2px 6px 0px rgba(153, 153, 153, 0.2);
    cursor: pointer;
    i {
      color: #c5c5c5;
      font-size: 12px;
    }
  }
}
</style>

<style>
.box-card-enter-active,
.box-card-leave-active {
  transition: all 0.5s;
}

.box-card-enter,
.box-card-leave-to {
  opacity: 0;
  transform: translateY(-20px);
}
</style>
